<?php

class WSB_View_Helper_Translate
{

    public function translate($string)
    {
    	static $translate = null;
    	if(empty($translate)) {
			$translate = Zend_Registry::get('Zend_Translate');
			$locale = Zend_Registry::get('Zend_Locale');
	        $moduleName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
	        $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
			$translation = sprintf(
				'%s/../etc/%s.%s.csv',
				Zend_Controller_Front::getInstance()->getControllerDirectory($moduleName),
				strtolower($controllerName),
				$locale
			);
			if(is_file($translation)) {
				$translate->addTranslation($translation, $locale);
			}
    	}
		return $translate->translate($string);
    }

}
